package createThread.cn.tedu.threaddemo.test7;

import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            System.out.println("t1线程开始");
            for (int i = 1; i <= 5 ; i++) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t1线程结束");
        });
        Thread t2 = new Thread(()->{
            System.out.println("t2线程开始");
            for (int i = 1; i <= 5 ; i++) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t2线程结束");
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("main线程执行完毕");
    }
}
